package org.nepu.scr.indexrate.converter;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.DataVo;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class DataVoConverter implements AttributeConverter<DataVo, String> {
    @Override
    public String convertToDatabaseColumn(DataVo dataVo) {
        return JSONUtil.toJsonStr(dataVo);
    }

    @Override
    public DataVo convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, DataVo.class);
    }
}
